{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 40,
   "id": "92d3e234",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]"
      ]
     },
     "execution_count": 40,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a = list(range(1,11))\n",
    "a\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "id": "8709f836",
   "metadata": {},
   "outputs": [],
   "source": [
    "a.insert(3,0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "id": "efea9fe7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[1, 2, 3, 0, 4, 5, 6, 7, 8, 9, 10]"
      ]
     },
     "execution_count": 43,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2690fcaa",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "c16f27cb",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "ename": "ZeroDivisionError",
     "evalue": "division by zero",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mZeroDivisionError\u001b[0m                         Traceback (most recent call last)",
      "\u001b[1;32m~\\AppData\\Local\\Temp/ipykernel_7944/2909670020.py\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m      1\u001b[0m \u001b[0mb\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;33m[\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      2\u001b[0m \u001b[1;32mfor\u001b[0m \u001b[0mi\u001b[0m \u001b[1;32min\u001b[0m \u001b[0ma\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 3\u001b[1;33m     \u001b[0mc\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;36m10\u001b[0m \u001b[1;33m/\u001b[0m \u001b[0mi\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m      4\u001b[0m     \u001b[0mb\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mappend\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mc\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      5\u001b[0m \u001b[0mb\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;31mZeroDivisionError\u001b[0m: division by zero"
     ]
    }
   ],
   "source": [
    "b = []\n",
    "for i in a:\n",
    "    c = 10 / i\n",
    "    b.append(c)\n",
    "b"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "8881ae7c",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "i当前为： 0\n",
      "i当前索引为： 3\n"
     ]
    }
   ],
   "source": [
    "b = []\n",
    "try:\n",
    "    \n",
    "    for i in a:\n",
    "        c = 10 / i\n",
    "        b.append(c)\n",
    "except:\n",
    "    print('i当前为：',i)\n",
    "    print('i当前索引为：',a.index(i))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "918a9e31",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[10.0, 5.0, 3.3333333333333335]"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "b"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "321d8352",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[10.0,\n",
       " 5.0,\n",
       " 3.3333333333333335,\n",
       " 'i出错了0',\n",
       " 2.5,\n",
       " 2.0,\n",
       " 1.6666666666666667,\n",
       " 1.4285714285714286,\n",
       " 1.25,\n",
       " 1.1111111111111112,\n",
       " 1.0]"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "b1 = []\n",
    "for i in a:\n",
    "    try:\n",
    "        c = 10 / i\n",
    "        b1.append(c)\n",
    "    except:\n",
    "        d = f'i出错了{i}'\n",
    "        b1.append(d)\n",
    "b1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "1ed79273",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['i当前为：', 0]\n"
     ]
    }
   ],
   "source": [
    "list_test = [1,2,3,4]\n",
    "print(list_test)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "eed385ad",
   "metadata": {},
   "source": [
    "c = 'i当前为：',i\n",
    "print(c)\n",
    "type(c)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "5f1e2b9b",
   "metadata": {},
   "outputs": [],
   "source": [
    "d = 1,2,3,4,4,"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "2fe358ec",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "tuple"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type(d)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "3ea7a26b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "tuple"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type(c)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "98c155da",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "('i当前为：', 0, [1, 2, 3, 4])"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cc = 'i当前为：',0,[1,2,3,4]\n",
    "cc"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "42189645",
   "metadata": {},
   "outputs": [],
   "source": [
    "a = ''\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "id": "42a0d42e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "i当前为： 0\n",
      "i当前索引为： 3\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "(1, 2, 3, 4, 5, 6)"
      ]
     },
     "execution_count": 45,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "b = []\n",
    "try:\n",
    "    \n",
    "    for i in a:\n",
    "        c = 10 / i\n",
    "        b.append(c)\n",
    "except:\n",
    "    print('i当前为：',i)\n",
    "    print('i当前索引为：',a.index(i))\n",
    "finally:\n",
    "    b = 1,2,3,4,5,6\n",
    "b"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "id": "7313eea0",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "i当前为： 0\n",
      "i当前索引为： 3\n"
     ]
    }
   ],
   "source": [
    "b = []\n",
    "try:\n",
    "    \n",
    "    for i in a:\n",
    "        c = 10 / i\n",
    "        b.append(c)\n",
    "except:\n",
    "    print('i当前为：',i)\n",
    "    print('i当前索引为：',a.index(i))\n",
    "\n",
    "b = 1,2,3,4,5,6\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "id": "a57f24e3",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "''"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "567a5c40",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
